const gulp = require('gulp')
const csv=require('csvtojson');
const JSON5=require('json5');
const fs = require('fs');


gulp.task('default', function() {
  const csvFilePath = "./data.csv"

  csv()
    .fromFile(csvFilePath)
    .then((jsonObj)=>{
      jsonObj = JSON5.stringify(jsonObj, null, 2)
      fs.writeFile("./newData.json5",jsonObj,'utf-8', function(err) {
        if(err) {
          return console.log(err);
        }

        console.log("The file was saved!");
      })
    })
  console.log("Hello Gulp!")
  return new Promise((resolve) => {
    resolve()
  })
})

gulp.task('lint', function() {
  return gulp.src([
    '*./source/ts/**/**.ts', './test/**/**.test.ts'
  ]).pipe(tslint())
    .pipe(tslint.report('verbose'))
})
